import Vue from 'vue'
import VeeValidate ,{ Validator } from "vee-validate";
import zh_CN from "vee-validate/dist/locale/zh_CN";
import VueI18n from 'vue-i18n';


//自定义valitate
const dictionary = {
    zh_CN: {      
       messages:{          
           required:function(field){
                return '请输入'+field          
           }      
       },      
       attributes: {
           name:'姓名',
           mobile:'手机号'//新增手机号属性
       }  
     }      
} 

Validator.localize(dictionary);
////
/**自定义手机验证 */
Validator.extend("mobile", {
    getMessage: field  => `请输入正确的手机号码`,
    validate: value => value.length === 11 && /^(((13[0-9]{1})|(14[57]{1})|(15[012356789]{1})|(17[03678]{1})|(18[0-9]{1})|(19[89]{1})|(16[6]{1}))+\d{8})$/.test(value) 
});   
//////////////////////////////

Vue.use(VueI18n);
const i18n = new VueI18n({
  locale: 'zh_CN'
});

Vue.use(VeeValidate,{
    i18n,
    i18nRootKey: 'validation',
    dictionary: {
        zh_CN      
    }  
});

// export 